import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {
  id?: number,
  parentId?: number,
  unityName?: string,
  unityType?: number,
  contactName?: string,
  contactPhone?: string,
  remark?: string,
  unityRole?: number[],
  superUser?: string,
  superUserPassword?: string,
  parentName?: string,
  unityRoleObj?:any[],
  allowAccountLogin?:any
}
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = '/system/system/v2/unity/unities';
const Url = '/system/system/v2/unity/unity';
export const getList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", List, {
    params
  });
};
export const getInfo = (params?: object) => {
  return http.request<commonResult<{data:infoType,perms:any[]}>>("get", Url, {
    params
  });
};
export const addInfo = (data?: object) => {
  return http.request<commonResult<any>>("post", Url, {
    data
  });
};
export const editInfo = (data?: object) => {
  return http.request<commonResult<any>>("put", Url, {
    data
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};
/** 1.2.12.7 查询单位树 */
export const getUnitTree = (params?: object) => {
  return http.request<commonResult<any>>("get", '/system/system/v2/unity/tree', {
    params
  });
};
/** 1.2.12.6 单位查询(所属单位下拉框) */
export const getUnitList = (params?: object) => {
  return http.request<commonResult<any[]>>("get", '/system/system/v2/unity/unitys', {
    params
  });
};